lgrind(1) lgrind(1)
NAME
lgrind - grind nice program listings using LaTeX
SYNOPSIS
lgrind [ -e ] [ -i ] [ - ] [ -n ] [ -h <header> ] [ -d
<description file> ] [ -l<language> ] <name> ...
DESCRIPTION
Lgrind formats program sources in a nice style using
(La)TeX(1). Comments are placed in roman, keywords in
bold face, variables in italics, and strings in typewriter
font. Source file line numbers appear in the right margin
(every 10 lines).
Lgrind processes its input file(s) and writes the result
to standard output. This output can be saved for later
editting, inclusion in a larger document, etc.
The options are:
-e process a LaTeX file for embedded text.
-i process for inclusion in a LaTeX document.
- take input from standard input.
-n don't boldface keywords.
-h specifies text to go on the left side of every out-
put page (default is none).
-d specifies the language definitions file (default is
/cs/lib/lgrindefs).
-l specifies the language to use. Currently known are
C (-lc or the default), C++ (-lc++ or -lCC), PASCAL
(-lp), Modula-2 (-lm2), Fortran (-lf), RATFOR
(-lr), Yacc (-ly), PostScript (-lps), Prolog
(-lprolog), MLisp (-lmlisp), Icon (-lI), TeX
(-ltex), Metafont (-lmf), Perl (-lperl), CSH
(-lcsh), Bourne Shell (-lsh) assembler (-lasm),
68000 assembler (-la68), asm68 (-lasm68), VMS
assembler (-lvmsasm), ISP (-lisp), LDL (-lldl),
Linda (-llinda), MODEL (-lm), and Russell (-lrus-
sell).
If neither -e nor -i are specified, a complete LaTeX file
is produced.
USAGE
For example, to include a C file named foo.c into your
LaTeX document, first give the command:
1
lgrind(1) lgrind(1)
lgrind -i -lc foo.c > foo.tex
This will generate foo.tex, which will have the pretty-
printed version of foo.c with a lot of LaTeX commands.
Then include lgrind.sty as you include any other style,
namely with the line
at the beginning of your LaTeX document. Having done this,
within the document you can include foo.tex using one of
the following commands:
foo.tex
which will simply include the file at that point of
text, and will draw horizontal lines before and
after the listing.
[htbp]foo.texcaptionlabel
which will put the listing also within a figure
environment, using the float options, caption and
label you gave.
To produce a standalone LaTeX file from, say, a Yacc file:
lgrind bary.y > bary.tex
This uses Piet van Oostrum's fancyheadings.sty to
make the headers and footers.
For a more detailed explanation of these commands, refer
to /cs/lib/tex/inputs/lgrind.doc.
EMBEDDED PROGRAMS WITHIN A LaTeX FILE
(From Jerry Leichter's notes.)
Within the text of your LaTeX file, you mark groups of
lines as either text- or display-style program code:
Text style:
The expression